package com.xgq.drink.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xgq.drink.entity.Orders;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xgq.drink.entity.Product;
import com.xgq.drink.entity.dto.CompositeOrderQuery;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 订单表 服务类
 * </p>
 *
 * @author xgq
 * @since 2025-03-03
 */
public interface IOrderService extends IService<Orders> {
    public List<Orders> saveOrder(List<Product> products, Long userId, Long addressId);
    public IPage<Orders> getOrderList(int current, int size, String status);
    public Orders updateOrderStatus(Orders order);
    public Orders updateOrder(Orders order);
    public Orders cancelOrder(Orders order, String reason);
    public Orders getOrderById(String orderId);
    public void confirmReceipt(Long orderId, Long userId);
    public void refundOrder(Orders order, String reason);
    public IPage<Orders> getCompositeOrders(CompositeOrderQuery query);

    // 新增商家查询订单方法
    public IPage<Orders> getBrandOrderList(Long brandId, int current, int size, Integer status);
    
    // 新增商家发货方法
    public Orders shipOrder(Long orderId, String logisticsNumber);
    IPage<Orders> getUserOrderList(Long userId, int current, int size, Integer status);
    // 新增商家关闭订单方法
    public Orders closeBrandOrder(Long orderId, String reason);
    /**
     * 获取指定品牌在指定时间范围内的订单数
     * @param brandId 品牌 ID
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return 订单数
     */
    Integer getOrderCountByBrandIdAndTimeRange(Long brandId, LocalDateTime startTime, LocalDateTime endTime);

    /**
     * 获取指定品牌在指定时间范围内的成交金额
     * @param brandId 品牌 ID
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return 成交金额
     */
    BigDecimal getTotalAmountByBrandIdAndTimeRange(Long brandId, LocalDateTime startTime, LocalDateTime endTime);
}
